<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Event callbacks</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="event.persistence.html">About event persistence</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="event.constructing.signal.events.html">Constructing signal events</a></div>
 <div class="up"><a href="book.event.html">Event</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="event.callbacks" class="chapter">
 <h1>Event callbacks</h1>

 <p class="para">
  If a callback is registered for an event, it will be called when the event
  becomes active. To associate a callback with event one can pass a
  <span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span>
  to whether
  <span class="methodname"><a href="event.construct.html" class="methodname">Event::__construct()</a></span>
  , or
  <span class="methodname"><a href="event.set.html" class="methodname">Event::set()</a></span>
  , or one of the factory methods like
  <span class="methodname"><a href="event.timer.html" class="methodname">Event::timer()</a></span>
  .
 </p>
 <p class="para">
  An event callback should match the following prototype:
 </p>
 <div class="methodsynopsis dc-description">
  <span class="type"><span class="type void">void</span></span> 
  <span class="methodname"><strong>callback</strong></span>
   ([ <span class="methodparam">
   <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span>
    <code class="parameter">$fd</code>
   <span class="initializer"> = <strong><code>NULL</code></strong></span>
  </span>
  [, <span class="methodparam">
   <span class="type">int</span>
    <code class="parameter">$what</code>
  </span>
  [, <span class="methodparam">
   <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span>
    <code class="parameter">$arg</code>
   <span class="initializer"> = <strong><code>NULL</code></strong></span>
  </span>
 ]]] )</div>

 <p class="para">
  <dl>

   
    <dt>

     <em><code class="parameter">fd</code></em>
    </dt>

    <dd>

     <p class="para">
      The file descriptor, stream resource or socket associated with the
      event. For signal event
      <em><code class="parameter">fd</code></em>
      is equal to the signal number.
     </p>
    </dd>

   
   
    <dt>

     <em><code class="parameter">what</code></em>
    </dt>

    <dd>

     <p class="para">
      Bit mask of
      <em class="emphasis">all</em>
      events triggered.
     </p>
    </dd>

   
   
    <dt>

     <em><code class="parameter">arg</code></em>
    </dt>

    <dd>

     <p class="para">
      User custom data.
     </p>
    </dd>

   
  </dl>

 </p>
 <p class="para">
  <span class="methodname"><a href="event.timer.html" class="methodname">Event::timer()</a></span>
  expects the callback to match the following prototype:
 </p>
 <div class="methodsynopsis dc-description">
  <span class="type"><span class="type void">void</span></span> 
  <span class="methodname"><strong>callback</strong></span>
   ([ <span class="methodparam">
   <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span>
    <code class="parameter">$arg</code>
   <span class="initializer"> = <strong><code>NULL</code></strong></span>
  </span>
 ] )</div>

 <p class="para">
  <dl>

   
    <dt>

     <em><code class="parameter">arg</code></em>
    </dt>

    <dd>

     <p class="para">
      User custom data.
     </p>
    </dd>

   
  </dl>

 </p>
 <p class="para">
  <span class="methodname"><a href="event.signal.html" class="methodname">Event::signal()</a></span>
  expects the callback to match the following prototype:
 </p>
 <div class="methodsynopsis dc-description">
  <span class="type"><span class="type void">void</span></span> 
  <span class="methodname"><strong>callback</strong></span>
   ([ <span class="methodparam">
   <span class="type">int</span>
    <code class="parameter">$signum</code>
  </span>
  [, <span class="methodparam">
   <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span>
    <code class="parameter">$arg</code>
   <span class="initializer"> = <strong><code>NULL</code></strong></span>
  </span>
 ]] )</div>

 <p class="para">
  <dl>

   
    <dt>

     <em><code class="parameter">signum</code></em>
    </dt>

    <dd>

     <p class="para">
      The number of the triggered signal(e.g.
      <strong><code>SIGTERM</code></strong>
      ).
     </p>
    </dd>

   
   
    <dt>

     <em><code class="parameter">arg</code></em>
    </dt>

    <dd>

     <p class="para">
      User custom data.
     </p>
    </dd>

   
  </dl>

 </p>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="event.persistence.html">About event persistence</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="event.constructing.signal.events.html">Constructing signal events</a></div>
 <div class="up"><a href="book.event.html">Event</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
